// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Analysis;

public sealed partial class IcuFoldingTokenFilter : ITokenFilter
{
	[JsonInclude, JsonPropertyName("type")]
	public string Type => "icu_folding";

	[JsonInclude, JsonPropertyName("unicode_set_filter")]
	public string UnicodeSetFilter { get; set; }
	[JsonInclude, JsonPropertyName("version")]
	public string? Version { get; set; }
}

public sealed partial class IcuFoldingTokenFilterDescriptor : SerializableDescriptor<IcuFoldingTokenFilterDescriptor>, IBuildableDescriptor<IcuFoldingTokenFilter>
{
	internal IcuFoldingTokenFilterDescriptor(Action<IcuFoldingTokenFilterDescriptor> configure) => configure.Invoke(this);

	public IcuFoldingTokenFilterDescriptor() : base()
	{
	}

	private string UnicodeSetFilterValue { get; set; }
	private string? VersionValue { get; set; }

	public IcuFoldingTokenFilterDescriptor UnicodeSetFilter(string unicodeSetFilter)
	{
		UnicodeSetFilterValue = unicodeSetFilter;
		return Self;
	}

	public IcuFoldingTokenFilterDescriptor Version(string? version)
	{
		VersionValue = version;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("type");
		writer.WriteStringValue("icu_folding");
		writer.WritePropertyName("unicode_set_filter");
		writer.WriteStringValue(UnicodeSetFilterValue);
		if (!string.IsNullOrEmpty(VersionValue))
		{
			writer.WritePropertyName("version");
			writer.WriteStringValue(VersionValue);
		}

		writer.WriteEndObject();
	}

	IcuFoldingTokenFilter IBuildableDescriptor<IcuFoldingTokenFilter>.Build() => new()
	{
		UnicodeSetFilter = UnicodeSetFilterValue,
		Version = VersionValue
	};
}